package com.kool.kadmin.mqtt.controller;

import com.kool.kadmin.common.bean.ListResult;
import com.kool.kadmin.common.bean.ObjectResult;
import com.kool.kadmin.common.util.ResultUtil;
import com.kool.kadmin.mqtt.service.DashboardService;
import com.kool.kadmin.mqtt.vo.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author luyu
 * @date 2021-04-19 17:24
 */
@RestController
public class DashboardController {
    @Resource
    private DashboardService dashboardService;

    /**
     * 查询dashboard实时指标
     *
     * @return
     */
    @PostMapping("/mqtt/getRealtimeMetrics")
    public ObjectResult<DashboardRealtimeMetrics> getRealtimeMetrics() {
        return ResultUtil.success(dashboardService.getRealtimeMetrics());
    }

    /**
     * 查询dashboard一个月的日报表
     *
     * @return
     */
    @PostMapping("/mqtt/getDailyReport")
    public ListResult<DashboardDailyReport> getDailyReport() {
        return ResultUtil.success(dashboardService.getDailyReport());
    }

    /**
     * 查询dashboard主题top统计
     *
     * @return
     */
    @PostMapping("/mqtt/getTopicTop")
    public ObjectResult<DashboardTopicTop> getTopicTop() {
        return ResultUtil.success(dashboardService.getTopicTop());
    }

    /**
     * 查询dashboard用户top统计
     *
     * @return
     */
    @PostMapping("/mqtt/getUserTop")
    public ObjectResult<DashboardUserTop> getUserTop() {
        return ResultUtil.success(dashboardService.getUserTop());
    }

    /**
     * 查询dashboard客户端top统计
     *
     * @return
     */
    @PostMapping("/mqtt/getClientTop")
    public ObjectResult<DashboardClientTop> getClientTop() {
        return ResultUtil.success(dashboardService.getClientTop());
    }
}
